﻿using System;
using System.Collections.Generic;
using System.Text;

namespace MineGoogleTranslator.Core
{
	public class LanguagePair
	{
		public LanguagePair(Language from, Language to)
			: this(from, to, true)
		{
		}

		private LanguagePair(Language from, Language to, bool ensure)
		{
			if (ensure)
				EnsureLanguages(from, to);
			From = from;
			To = to;
		}

		private void EnsureLanguages(Language from, Language to)
		{
			LanguagePair pair = new LanguagePair(from, to, false);
			switch (pair.ToString())
			{
				case "ar|en":
				case "en|nl":
				case "en|fr":
				case "en|de":
				case "en|el":
				case "en|it":
				case "en|ja":
				case "en|ko":
				case "en|pt":
				case "en|ru":
				case "en|es":
				case "fr|de":
				case "de|fr":
				case "it|en":
				case "ja|en":
				case "ko|en":
				case "pt|en":
				case "ru|en":
				default:
					return;
			}
			throw new Exception("Language pair is invalid!");
		}

		private Language from;

		public Language From
		{
			get { return from; }
			set { from = value; }
		}

		private Language to;

		public Language To
		{
			get { return to; }
			set { to = value; }
		}

		public override bool Equals(object obj)
		{
			return ToString().Equals(obj.ToString());
		}

		public override String ToString()
		{
			return From.ToString() + "|" + To.ToString();
		}
	}
}
